package com.cdtye.itps.cms.dao.defect.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.*;
import com.cdtye.common.webcore.util.DateUtil;
import com.cdtye.itps.cms.dao.detect.JcjcDefectInfoSection;
import com.cdtye.itps.cms.dao.enums.DefectInfoStatusEnum;
import com.cdtye.itps.cms.dao.enums.DelFlagEnum;
import com.cdtye.itps.cms.dao.enums.StatusEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 *
 * @author wzw
 * @date 2021-12-21
 */
@ApiModel("缺陷信息")
@Data
@Accessors(chain = true)
@TableName("JCW_PROBLEM_DEFECT_INFO")
public class JcwProblemDefectInfo {
    @ApiModelProperty("ID")
    @TableId(
            type = IdType.UUID
    )
    private String id;
    @ApiModelProperty(value = "线路Id")
    private String lineId;

    @ApiModelProperty(value = "检测日期")
    private Date detectDate;

    @ApiModelProperty(value = "缺陷值")
    private String defectValue;

    @ApiModelProperty(value = "设备类型(高铁支柱，普通支柱)")
    private String equipType;

    @ApiModelProperty(value = "区站Id")
    private String lineSiteId;

    @ApiModelProperty(value = "支柱号Id")
    private String pillarId;

    @ApiModelProperty(value = "支柱号")
    private String pillarNum;

    @ApiModelProperty(value = "公里标")
    private Double roadMark;

    @ApiModelProperty(value = "支柱号所属工区(这里记录)")
    private String pillarDeptId;

    @ApiModelProperty(value = "隧道id")
    private String tunnelId;

    @ApiModelProperty(value = "发现人，存人名")
    private String findBy;

    @ApiModelProperty(value = "发现部门Id")
    private String findDeptId;

    @ApiModelProperty(value = "缺陷来源ID")
    private String defectOriginId;

    @ApiModelProperty(value = "缺陷等级ID")
    private String defectLevelId;

    @ApiModelProperty(value = "缺陷分类ID")
    private String defectCategoryId;

    @ApiModelProperty(value = "缺陷部位ID")
    private String defectPositionId;

    @ApiModelProperty(value = "发现日期")
    @DateTimeFormat(pattern = DateUtil.DATE_FORMAT)
    @JSONField(format = DateUtil.DATE_FORMAT)
    private Date findDate;

    @ApiModelProperty(value = "整改期限日期")
    @DateTimeFormat(pattern = DateUtil.DATE_FORMAT)
    @JSONField(format = DateUtil.DATE_FORMAT)
    private Date solveDate;

    @ApiModelProperty(value = "整改责任工区")
    private String solveWorkareaId;

    @ApiModelProperty(value = "缺陷描述")
    private String defectDescription;

    //2.这一块整改信息
    @ApiModelProperty(value = "缺陷成因ID")
    private String defectReasonId;

    @ApiModelProperty(value = "处理工区")
    private String handleWorkareaId;

    @ApiModelProperty(value = "处理人")
    private String handleBy;

    @ApiModelProperty(value = "处理日期")
    @DateTimeFormat(pattern = DateUtil.DATE_FORMAT)
    @JSONField(format = DateUtil.DATE_FORMAT)
    private Date handleDate;

    @ApiModelProperty(value = "销号情况（N：未销号(默认)；Y：已销号）")
    private String status;

    @ApiModelProperty(value = "处理描述")
    private String handleDescription;

    //3.这一块提交单位信息
    @ApiModelProperty(value = "单位Code")
    private String deptCode;

    @ApiModelProperty(value = "缺陷状态 0：未处理 1：已审核，2：下发，3：已整改，4：已销号")
    private String defectStatus;

    @ApiModelProperty(value = "c类型id")
    private String ctypeId;

    @ApiModelProperty(value = "复核日期")
    @DateTimeFormat(pattern = DateUtil.DATE_FORMAT)
    @JSONField(format = DateUtil.DATE_FORMAT)
    private Date checkDt;

    @ApiModelProperty(value = "复核人")
    private String reviewUser;

    @ApiModelProperty(value = "复核说明")
    private String reviewDesc;

    @ApiModelProperty(value = "缺陷部位code")
    private String defectPositionCode;

    @ApiModelProperty(value = "缺陷部位name")
    private String defectPositionName;

    @ApiModelProperty(value = "整改责任工区")
    private String respWorkArea;

    @ApiModelProperty(value = "处理工区")
    private String dealWorkArea;

    @ApiModelProperty(value = "行别id")
    private String directionId;

    @ApiModelProperty(value = "数据发现来源ID")
    private String discoverSourceId;

    @ApiModelProperty(value = "数据来自哪个系统")
    private String systemSource;

    @ApiModelProperty(value = "C类型：1C，2C，3C，4C，5C，6C")
    private String cType;

    @ApiModelProperty(value = "来源段code")
    private String unitDeptCode;

    @ApiModelProperty(value = "来源系统创建日期")
    @DateTimeFormat(pattern = DateUtil.DATE_FORMAT)
    @JSONField(format = DateUtil.DATE_FORMAT)
    private Date createDatetimeSource;

    @ApiModelProperty(value = "来源系统更新日期")
    @DateTimeFormat(pattern = DateUtil.DATE_FORMAT)
    @JSONField(format = DateUtil.DATE_FORMAT)
    private Date updateDatetimeSource;

    @ApiModelProperty(value = "检测任务id")
    private String detectJobId;
    @ApiModelProperty(value = "缺陷分类名称，冗余，防止分类 ID 匹配不成功")
    private String defectCategoryName;
    @ApiModelProperty(value = "是否下达整改通知书，0：未下达，1：已下达")
    private Integer reviseNotice;
    @ApiModelProperty(value = "超限原因")
    private String outRangeCause;
    @ApiModelProperty(value = "确认人")
    private String confirmName;
    @ApiModelProperty(value = "确认时间")
    @DateTimeFormat(pattern = DateUtil.DATETIME_FORMAT)
    @JSONField(format = DateUtil.DATETIME_FORMAT)
    private Date confirmTime;
    @ApiModelProperty(value = "确认人部门")
    private String confirmDeptName;
    @ApiModelProperty(value = "误检缺陷，或复测结果，0：未复测，1：误检缺陷（复测无缺陷），2：设备缺陷(复测有缺陷)")
    private Integer mistake;
    @ApiModelProperty(value = "复核类型")
    private String reviewType;
    @ApiModelProperty(value = "处理意见或情况")
    private String handleView;
    @ApiModelProperty(value = "复核结论")
    private String reviewResult;
    @ApiModelProperty(value = "缺陷描述id")
    private String defectDescId;

    @ApiModelProperty(value = "文件包Id")
    private String packageId;
    //"线路类型，枚举， 1：高速铁路、2：普速铁路"
    @ApiModelProperty(value = "线路类型")
    private String lineTypeCode;
    @ApiModelProperty(value = "设备名称")
    private String devName;
    @ApiModelProperty(value = "缺陷公里标")
    private String defectRoadMark;
    @ApiModelProperty(value = "缺陷地点")
    private String defectLoc;
    //填写时间 日期格式：yyyy-MM-dd HH:mm:ss
    @ApiModelProperty(value = "填写时间")
    private Date registerDate;
    //下发日期 日期格式：yyyy-MM-dd HH:mm:ss
    @ApiModelProperty(value = "下发日期")
    private Date publishDate;
    //销号日期 日期格式：yyyy-MM-dd HH:mm:ss
    @ApiModelProperty(value = "销号日期")
    private Date endDate;
    //下发人名称
    @ApiModelProperty(value = "下发人名称")
    private String publishUserName;
    //销号人名称
    @ApiModelProperty(value = "销号人名称")
    private String endName;
    //零部件编码
    @ApiModelProperty(value = "零部件编码")
    private String partCode;
    //零部件名称
    @ApiModelProperty(value = "零部件名称")
    private String partName;
    //"缺陷图片，：name 文件名 String xx.jpg; photoUrl 照片地址 String HTTPS://xx/xx.jpg"
    //"审批信息， 样例：[ {""name"": ""姓名"",""auditDate"": ""审批时间，yyyy-MM-dd HH:mm:ss"",auditDesc"": ""审批意见"",""auditResult"": ""审批结论,0：不通过，1：通过"",}]"
    @ApiModelProperty(value = "审批信息")
    private String auditInfo;
    //"复测图片， name 文件名 String xx.jpg;photoUrl 照片地址 String HTTPS://xx/xx.jpg; photoType 照片类型 String 1：杆号照片 2：复测照片"
    @ApiModelProperty(value = "复测图片")
    private String retestPhoto;
    //"整改图片，name 文件名 String xx.jpgphotoUrl 照片地址 String HTTPS://xx/xx.jpgphotoType 照片类型 String 1：杆号照片 2：整改前照片 3：整改后照片"
    @ApiModelProperty(value = "整改图片")
    private String dealPhoto;
    //"复核值，样例： [{""setloc"": ""支柱号"",""km"": ""公里标，k100+100"",""LCZ"": 10,""WD"": 12}]"
    @ApiModelProperty(value = "复核值")
    private String measureValue;
    //"整改值，样例：  [{""setloc"": ""支柱号"",""km"": ""公里标，k100+100"", ""LCZ"": 10,""WD"": 12}]"
    @ApiModelProperty(value = "整改值")
    private String dealValue;
    //"是否典型缺陷，枚举， 0：否、1：是
    @ApiModelProperty(value = "是否典型缺陷")
    private String isFavorite;
    @ApiModelProperty("更新人")
    @TableField(
            value = "UPDATE_BY",
            fill = FieldFill.INSERT_UPDATE
    )
    private String updateBy;
    @ApiModelProperty("创建人")
    @TableField(
            value = "CREATE_BY",
            fill = FieldFill.INSERT
    )
    private String createBy;
    @ApiModelProperty("创建时间")
    @TableField(
            value = "CREATE_DATETIME",
            fill = FieldFill.INSERT
    )
    private Date createDatetime;
    @ApiModelProperty("更新时间")
    @TableField(
            value = "UPDATE_DATETIME",
            fill = FieldFill.INSERT_UPDATE
    )
    private Date updateDatetime;

    @ApiModelProperty(value = "同步状态 0：未同步 1：同步失败 2：同步成功")
    private String sysnStatus;

    @ApiModelProperty("删除标志，Y=是，N=否")
    @TableField(value ="DEL_FLAG", fill = FieldFill.INSERT)
    private String delFlag;

    public JcjcDefectInfoSection covEntity() {
        JcjcDefectInfoSection jcjcDefectInfoSection = new JcjcDefectInfoSection();
        //缺陷描述
        jcjcDefectInfoSection.setDefectInfoDesc(this.defectDescription);
        //发现人， 发现日期
        jcjcDefectInfoSection.setDiscoverPerson(this.findBy);
        jcjcDefectInfoSection.setDiscoverDate(this.findDate);
        //处理人， 处理日期 ，处理描述
        jcjcDefectInfoSection.setSolvePersonal(this.handleBy);
        jcjcDefectInfoSection.setSolveDatetime(this.handleDate);
        jcjcDefectInfoSection.setSolveMethod(this.handleDescription);

        //缺陷销号状态 0：未销号 1：已销号
        if(this.status.equals("N")){
            jcjcDefectInfoSection.setStatus(DefectInfoStatusEnum.NO.value);

            jcjcDefectInfoSection.setInputAuditStatus(0);
            jcjcDefectInfoSection.setRectifAuditStatus(0);
        }
        if(this.status.equals("Y")){
            jcjcDefectInfoSection.setStatus(DefectInfoStatusEnum.YES.value);

            //处理工区   只有销号状态的才存
            jcjcDefectInfoSection.setHandleWorkareaId(this.handleWorkareaId);

            jcjcDefectInfoSection.setInputAuditStatus(2);
            jcjcDefectInfoSection.setRectifAuditStatus(2);
        }
        //缺陷流程状态
        jcjcDefectInfoSection.setDefectStatus(this.defectStatus);

        //整改期限
        if (this.solveDate != null) {
            jcjcDefectInfoSection.setRectifDatetime(this.solveDate);
        }

        jcjcDefectInfoSection.setCType(this.cType);
        jcjcDefectInfoSection.setSourceModel("TY");
        jcjcDefectInfoSection.setSystemSource("6C");
        jcjcDefectInfoSection.setCreateDatetimeSource(this.updateDatetimeSource);
        jcjcDefectInfoSection.setDiscoverSourceId(this.discoverSourceId);
        //责任整改工区
        jcjcDefectInfoSection.setSolveWorkareaId(this.solveWorkareaId);

        jcjcDefectInfoSection.setDelFlag("N");
        if (this.delFlag.equals("Y")) {
            jcjcDefectInfoSection.setDelFlag("Y");
        }
        return jcjcDefectInfoSection;
    }
}
